import 'package:flutter/material.dart';
import 'screens/auth/login_screen.dart';
import 'screens/home/home_screen.dart';
import 'screens/inbound/inbound_screen.dart';
import 'screens/inbound/checkin_screen.dart';
import 'screens/inbound/checkin_detail_screen.dart';
import 'screens/inbound/receiving_screen.dart';
import 'screens/inbound/receiving_detail_screen.dart';
import 'screens/inbound/receiving_detail_item_screen.dart';
import 'screens/inbound/putaway_screen.dart';
import 'screens/inbound/putaway_summary_screen.dart';
import 'screens/inbound/load_task_screen.dart';
import 'screens/inbound/putaway_detail_screen.dart';
import 'screens/inbound/putaway_tasks_screen.dart';
import 'screens/inbound/pack_detail_screen.dart';
import 'screens/outbound/outbound_screen.dart';
import 'screens/outbound/batch_picking_screen.dart';
import 'screens/outbound/bin_assignment_screen.dart';
import 'screens/outbound/single_picking_screen.dart';
import 'screens/outbound/shipment_screen.dart';
import 'screens/picking/picking_screen.dart';
import 'screens/picking/picking_detail_screen.dart';
import 'screens/inventory/inventory_screen.dart';
import 'screens/inventory/inv_adjustment_screen.dart';
import 'screens/inventory/inv_adjustment_detail_screen.dart';
import 'screens/inventory/cycle_count_screen.dart';
import 'screens/inventory/count_screen.dart';
import 'screens/inventory/physical_count_screen.dart';
import 'screens/inventory/move_stock_screen.dart';
import 'screens/inventory/move_screen.dart';
import 'screens/inventory/search_detail_screen.dart';


import 'screens/system/system_screen.dart';
import 'screens/system/fontsize_setting_screen.dart';

class AppRoutes {
  static Route<dynamic> generateRoute(RouteSettings settings) {

    // 添加路由重置点
    if (settings.name == '/reset') {
      return MaterialPageRoute(
        builder: (_) => const SizedBox.shrink(),
        settings: const RouteSettings(name: '/'),
      );
    }

    switch (settings.name) {
      case '/login':
        return MaterialPageRoute(builder: (_) => const LoginScreen());
      case '/home':
        return MaterialPageRoute(builder: (_) => const HomeScreen());
      case '/inbound':
        return MaterialPageRoute(builder: (_) => const InboundScreen());
      case '/inbound/checkin':
        return MaterialPageRoute(builder: (_) => const CheckinScreen());
      case '/inbound/checkin-detail':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => CheckinDetailScreen(jsonData:args));
      case '/inbound/receiving':
        return MaterialPageRoute(builder: (_) => const ReceivingScreen());
      case '/inbound/receiving-detail':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => ReceivingDetailScreen(jsonData:args));
      case '/inbound/receiving-detail-item':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => ReceivingDetailItemScreen(jsonData:args));
      case '/inbound/putaway':
        return MaterialPageRoute(builder: (_) => const PutawayScreen());
      case '/inbound/load-task':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => LoadTaskScreen(jsonData:args));
      case '/inbound/putaway-summary':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => PutawaySummaryScreen(jsonData:args));
      case '/inbound/putaway-tasks':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => PutawayTasksScreen(jsonData:args));
      case '/inbound/putaway-detail':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => PutawayDetailScreen(jsonData:args));
      case '/inbound/pack-detail':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => PackDetailScreen(jsonData:args));
      case '/outbound':
        return MaterialPageRoute(builder: (_) => const OutboundScreen());
      case '/outbound/batch-picking':
        return MaterialPageRoute(builder: (_) => const BatchPickingScreen());
      case '/outbound/single-picking':
        return MaterialPageRoute(builder: (_) => const SinglePickingScreen());
      case '/outbound/bin-assignment':
        return MaterialPageRoute(builder: (_) => const BinAssignmentScreen());
      case '/outbound/shipment':
        return MaterialPageRoute(builder: (_) => const ShipmentScreen());
      case '/picking/picking':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => PickingScreen(jsonData:args));
      case '/picking/picking-details':
        final args = settings.arguments as Map<String, dynamic>;
        return MaterialPageRoute(builder: (_) => PickingDetailScreen(jsonData:args));
      case '/inventory':
        return MaterialPageRoute(builder: (_) => const InventoryScreen());
      case '/inventory/inv-adjustment':
        return MaterialPageRoute(builder: (_) => const InvAdjustmentScreen());
      case '/inventory/inv-adjustment-detail':
        return MaterialPageRoute(builder: (_) => const InvAdjustmentDetailPage());
      case '/inventory/cycle-count':
        return MaterialPageRoute(builder: (_) => const CycleCountScreen());
      case '/inventory/count':
        return MaterialPageRoute(builder: (_) => const CountScreen());
      case '/inventory/physical-count':
        return MaterialPageRoute(builder: (_) => const PhysicalCountScreen());
      case '/inventory/move-stock':
        return MaterialPageRoute(builder: (_) => const MoveStockScreen());
      case '/inventory/move':
        return MaterialPageRoute(builder: (_) => const MoveScreen());
      case '/inventory/search-detail':
        return MaterialPageRoute(builder: (_) => const SearchDetaiScreen());
      case '/system':
        return MaterialPageRoute(builder: (_) => const SystemScreen());
      case '/system/fontsize_setting':
        return MaterialPageRoute(builder: (_) => const FontSizeSettingScreen());
      default:
        return MaterialPageRoute(
          builder: (_) => Scaffold(
            appBar: AppBar(title: const Text('page not found.'),backgroundColor: const Color(0xFF008363)),
            body: const Center(child: Text('page not exist.')),
          ),
        );
    }
  }
}